import 'package:aihu_getx_app/app/modules/d/d_home/controllers/d_home_controller.dart';
import 'package:aihu_getx_app/app/modules/d/d_my/models/user_profile_resp_vo.dart';
import 'package:aihu_getx_app/app/modules/d/d_my/providers/d_my_provider.dart';
import 'package:get/get.dart';

class DMyProfileDetailController extends DHomeController {
  final String title = "个人信息";
  final count = 0.obs;

  final userProfile = UserProfileRespVO().obs;
  final loading = false.obs;

  Future onRefresh() {
    if (loading.isTrue) {
      return Future.value();
    }
    onLoading();
    return Future.value();
  }

  void onLoading() async {
    loading.value = true;
    try {
      var res = await DMyProvider.getUserInfo();
      userProfile.value = res;
    } finally {
      loading.value = false;
    }
  }

  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
    onLoading();
  }

  @override
  void onClose() {
    super.onClose();
  }

  void increment() => count.value++;
}
